package 我的Java学习_算法基础.day_05;

import static 我的Java学习_算法基础.day_05.HeightArray.getHeight;
import static 我的Java学习_算法基础.day_05._085_字符串匹配之后缀数组_中.getSa2;

public class _089_后缀数组的应用_上 {
    public static void main(String[] args) {
        String s = "123232323";
        int n = maxRepeatSubString(s);
        System.out.println(n);
    }
    private static int maxRepeatSubString(String src){
        Suff[] sa = getSa2(src);
        int[] height = getHeight(src,sa);
        int maxHeight = 0;
        int maxIndex = -1;
        for(int i = 0;i<height.length;i++){
            if(height[i]>maxHeight){
                maxHeight = height[i];
                maxIndex = i;
            }
        }
        int index = sa[maxIndex].index;
        System.out.println(src.substring(index,index+maxHeight));
        return maxHeight;
    }
}
